﻿using Gasgoo.ShareLibrary.Framework.ServiceDefine;
using IToolLogger.Interface;
using Orleans.Streams;

namespace IToolLoggerService;

public class ImplicitSubscriberService : GasgooSubscriberServiceBase<string>, IImplicitSubscriberService
{
    public ImplicitSubscriberService() : base("test", "order")
    {
    }

    public override Task OnActivateAsync()
    {
        Console.WriteLine("~~OnActivateAsync!!!!!!!!!");
        return base.OnActivateAsync();
    }

    public override async Task OnCompletedAsync()
    {
        Console.WriteLine("OnCompletedAsync");
        await Task.CompletedTask;
    }

    public override async Task OnErrorAsync(Exception ex)
    {
        Console.WriteLine("OnErrorAsync: is {0}", ex);
        await Task.CompletedTask;
    }

    public override async Task OnNextAsync(string item, StreamSequenceToken token)
    {
        Console.WriteLine("OnNextAsync: is {0},,,,,{1}", item, token);
        if (item.Contains("val is 1"))
        {
            throw new Exception("trigger error");
        }
        await Task.CompletedTask;
    }
}
